package com.situ.mall.oop;

import org.junit.jupiter.api.Test;



public class Demo {
    public static void main(String[] args) {
        String str1 = new StringBuilder("58").append("tongcheng").toString();
        System.out.println(str1);//58tongcheng
        System.out.println(str1.intern());//58tongcheng
        System.out.println((str1 == str1.intern()));//true
    }

    @Test
    public void test1() {
        Person p1 = new Person(18);
        Person p2 = p1.clone();
        p2.age = 20;
        p2.arr[0] = 10;

        System.out.println(p1 == p2);//false
        System.out.println(p1.age);//18
        System.out.println(p1.arr[0]);//10
    }

    @Test
    public void test23() {
        Integer a = 10;
        Integer b = 10;
        Integer c = 129;
        Integer d = 129;
        Integer e = new Integer(13);
        Integer f = new Integer(13);
        System.out.println(a == b);
        System.out.println(c == d);
        System.out.println(e == f);// new出来的对象是在堆里面地址值肯定不一样
    }

    @Test
    public void test44() {
        //情景1
        Integer c = 128;
        Integer d = 128;
        System.out.println(c == d);//false

        //情景2
        Integer a = 1;
        Integer b = 1;
        System.out.println(a == b);//true

        //情景3
        //Integer e = new Integer(1);
        //Integer f = new Integer(1);
        Integer e = Integer.valueOf(1);
        Integer f = Integer.valueOf(1);
        System.out.println(e == f);//false
    }
}
